﻿
@using KRM.Core.Library
@model KRM.Core.vKRWNewSiteSubmission
@{
    ViewBag.Title = "SiteSubmission";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    var assignedTo = string.IsNullOrEmpty(Model.assignedTo) ? 0 : Model.UserAssigned;
    var userId = Users.Current(User.Identity.Name).UserID;
}
@Html.Partial("Partial/_MessageResult")
<script>
    $(document).ready(function() {
        $(".btn-answered").click(function() {
            $("#hfaction").val("answered");
            $(this).attr("type", "submit");
            $(this).trigger("click");
        });
        $(".btn-clearoff").click(function() {
            $("#hfaction").val("clearoff");
            $(this).attr("type", "submit");
            $(this).trigger("click");
        });
        $(".btn-saveandclose").click(function() {
            $("#hfaction").val("saveandclose");
            $(this).attr("type", "submit");
            $(this).trigger("click");
        });
        $(".btn-sendreply").click(function() {
            $("#hfaction").val("sendreply");
            $(this).attr("type", "submit");
            $(this).trigger("click");
        });
        $(".btn-retrieve").click(function () {
            $("#hfaction").val("retrieve");
            $(this).attr("type", "submit");
            $(this).trigger("click");
        });
    });
    function setanotheruser() {
        $("#hfaction").val("setanotheruser");
        $("#fr-sitesubmission").submit();
    }
</script>
<div style="padding: 10px">
    <form action="/task/ActionSiteSubmission" method="POST" class="margin0" id="fr-sitesubmission">
        <input type="hidden" name="SiteQuestionID" value="@Model.SiteQuestionID"/>
        <input type="hidden" name="action" id="hfaction" />
        <div class="row-fluid">
            <div class="span2">Assigned to:</div>
            <div class="span4">
                <input type="text" disabled="disabled" value="@(string.IsNullOrEmpty(Model.assignedTo) ? "NOT Assigned" : Model.assignedTo)" class="input-block-level"/>
            </div>
            @if (assignedTo == 0)
            {
                <div class="span2">
                    <input type="button" class="btn btn-retrieve" value="Retrieve" />
                </div>
            }
            <div class="span4">
                <input type="text" disabled="disabled" value="@Model.dateposted" class="input-block-level"/>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span6">
                <input type="text" disabled="disabled" value="@Model.email" class="input-block-level"/>
            </div>
        </div>
        <fieldset>
            <legend>Question</legend>
            <div class="row-fluid">
                <textarea class="input-block-level" disabled="disabled" rows="5">@Model.Question</textarea>
            </div>
            <a href="@Model.ProductURL" target="_blank">@Model.ProductName</a>
        </fieldset>
        <fieldset>
            <legend>Answers</legend>
            <div class="row-fluid">
                <textarea class="input-block-level" name="answer" @(assignedTo != userId ? "readonly=readonly" : "") rows="10">
@(assignedTo == userId ? "<---Please Enter Your answer--->" : Model.answer)
</textarea>
            </div>
        </fieldset>
        <div class="row-fluid">
            <div class="span6"></div>
            <div class="span6">
                <label style="float: left; margin-right: 15px">
                    <input type="checkbox" class="cbcheck" checked="checked" disabled="disabled" />
                    Display on Site
                </label>
                <label>
                    <input type="checkbox" class="cbcheck" name="saveaspop" />
                    Save as popular answer
                </label>
            </div>
        </div>
        <div class="row-fluid">
            <input type="button" class="btn btn-info btn-answered" value="Answered by phone" />
            @if (assignedTo == userId)
            {
                <input type="button" class="btn btn-clearoff" value="Clear off Question without answer" />
                <input type="button" class="btn btn-success btn-saveandclose" value="Save and close but don't send yet" />
                <input type="button" class="btn btn-primary btn-sendreply" value="Send Reply" />
            }

        </div>
    </form>
</div>
